package com.woniu.inlet.web;

import com.woniu.outlet.po.OrderProduction;
import com.woniu.service.OrderProductionService;
import com.woniu.util.ResponseResult;
import com.woniu.util.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@RestController
@Api(tags = "发送消息队列至生产计划")
@RequestMapping("/order/")
public class OrderProductionController {

    @Autowired
    private OrderProductionService orderProductionService;

    //根据订单编号查询订单商品明细
    @GetMapping("findOrderProductionByOrderNo")
    @ApiOperation("查询并发送订单生产计划(根据订单编号)")
    public ResponseResult<List<OrderProduction>> findOrderProductionByOrderNo(@Valid String orderNo) throws Exception{
        List<OrderProduction> OrderProductions = orderProductionService.findOrderProductionByOrderNo(orderNo);
        if(OrderProductions == null){
            return new ResponseResult<>(OrderProductions, "该订单暂无需生产计划", ResultCode.ORDERNO_IS_NOT_EXIST.getCode());
        }
        return new ResponseResult<>(OrderProductions, "OK", ResultCode.SUCCESS.getCode());
    }

}
